<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="com.coo1.onlineorder.server.data.MSTADMIN" %>
<%@ page import="com.coo1.onlineorder.server.dataStore" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="javax.jdo.Query" %>
<%@ page import="com.coo1.onlineorder.server.PMF" %>
<%@ page import="java.util.ArrayList" %>


<html>
  <body>
      <p>
      <%
		String username = (String)session.getAttribute("username");
		List<MSTADMIN> results;
		String msg = null;
		//dataStore ds = new dataStore();

		PersistenceManager pm = PMF.get().getPersistenceManager();
      pm = PMF.get().getPersistenceManager();
      
		if (username.isEmpty()) {
			Query query = pm.newQuery(MSTADMIN.class);
			results = (List<MSTADMIN>) query.execute();
		}else{
			Query query = pm.newQuery(MSTADMIN.class,"username == USERNAMEParam");
      	query.declareParameters("String USERNAMEParam");
			results = (List<MSTADMIN>) query.execute(username);
		}

		if (results.isEmpty()){
			msg =  "該当ユーザありません！！！";
		}
      if(msg == null){
    	  dataStore ds= new dataStore();
    	 for(int i = results.size();i>0;i--){%>
    		 <%=(String)results.get(i-1).getUserName()%>,<%=(String)results.get(i-1).getPassword()%></p><p>
    	 <%}
    	 ArrayList<dataStore> alds = (ArrayList<dataStore>)session.getAttribute("USERLIST");
    	 for(int i = 0;i<alds.size();i++){
    	 	ds = alds.get(i);%>
		 <%=ds.getUser()%>,<%=ds.getPass()%></p><p>
	 <%}
      }else{%>
      <%=msg%>
    	 
     <%}
     %>
     </p>
     <p><%=(String)session.getAttribute("MSG")%></p>
  </body>
</html>
